package offer;

import java.util.LinkedList;

public class offerII_0042 {
    class RecentCounter {
        LinkedList<Integer> list;
        int num;
        public RecentCounter() {
            num=0;
            list=new LinkedList<>();
        }

        public int ping(int t) {
            while(!list.isEmpty()&&list.getFirst()<t-3000){
                list.removeFirst();
                num--;
            }
            list.add(t);
            num++;
            return num;
        }
    }
}
